<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib prefix="s" uri="/struts-tags"%> 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'FeedData_JS.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">

<script type="text/javascript" src="./FusionWidgets/FusionCharts.js"></script>
<script type="text/javascript" src="./ui/js/jquery.js"></script>
<link href="assets/ui/css/style.css" rel="stylesheet" type="text/css" />
        <!--[if IE 6]>
        <script type="text/javascript" src="../assets/ui/js/DD_belatedPNG_0.0.8a-min.js"></script>
		<script>
          /* select the element name, css selector, background etc */
          DD_belatedPNG.fix('img');

          /* string argument can be any CSS selector */
        </script>
        <![endif]-->
          	<script type="text/javascript">
				var TaskId = ${sessionScope.taskId};
				var TaskKind = ${sessionScope.taskKind};
        		function feedData(){
		 		var chartRef = FusionCharts("ChId1");
		 		var params = {
		          taskId : TaskId, 
		       	  taskKind : TaskKind
		       };
		       $.ajax({
		   		type: "POST",
		   		url: "chartForCPU.action",    //提交的地址
		   		data: params,
		    	dataType:"text",            //ajax返回值设置为text（json格式也可用它返回，可打印出结果，也可设置成json）
		    	success: function(json){  
		    	var obj = $.parseJSON(json);  //使用这个方法解析json
		        var dataParameters = obj.dataParameters;  //dispatchResult是和action中定义的dispatchResult变量的get方法对应的
		       	//alert(dataParameters);
		        chartRef.feedData(dataParameters);
		    	},
		    	error: function(json){
		    		alert("返回数据失败！！");
		   		 }
		    	});
		    	setTimeout("feedData()", 3000);
		 	}

		   //$("#btnFeed").click(function() {
		   	
		 //  });
	</script>
</head>
<body onload="feedData()">
<div id="chart1div" style="margin: 0 auto;">
  This text is replaced by the chart.
</div>
<!--<s:if test="%{taskKind=='CPU使用率'}">-->
<script type="text/javascript">
   var chart1 = new FusionCharts("./FusionWidgets/RealTimeArea.swf", "ChId1", "500", "350", "0", "1");
   chart1.setXMLData("<chart caption='CPU使用率实时折线图' \n\
numberSuffix='%' yAxisMaxValue='100' setAdaptiveYMin='1' xAxisName='Time' showRealTimeValue='1' labelDisplay='Rotate' slantLabels='1' numDisplaySets='15' canvasBottomMargin='130'	>\n\
	<categories>\n\
	</categories>\n\
	<dataset seriesName='CPU' showValues='0'>\n\
	</dataset>\n\
	<styles>\n\
		<definition>\n\
			<style type='font' name='captionFont' size='14' />\n\
		</definition>\n\
		<application>\n\
			<apply toObject='Caption' styles='captionFont' />\n\
			<apply toObject='Realtimevalue' styles='captionFont' />\n\
		</application>\n\
	</styles>\n\
</chart>");
   chart1.render("chart1div");
</script>
<!--</s:if>
<s:if test="%{taskKind=='TotalRAMused'}">
<script type="text/javascript">
   var chart1 = new FusionCharts("./FusionWidgets/RealTimeArea.swf", "ChId1", "500", "350", "0", "1");
   chart1.setXMLData("<chart caption='Memory使用量实时折线图' \n\
numberSuffix='MB' yAxisMaxValue='2048' setAdaptiveYMin='1' xAxisName='Time' showRealTimeValue='1' labelDisplay='Rotate' slantLabels='1' numDisplaySets='15' canvasBottomMargin='130'	>\n\
	<categories>\n\
	</categories>\n\
	<dataset seriesName='Memory' showValues='0'>\n\
	</dataset>\n\
	<styles>\n\
		<definition>\n\
			<style type='font' name='captionFont' size='14' />\n\
		</definition>\n\
		<application>\n\
			<apply toObject='Caption' styles='captionFont' />\n\
			<apply toObject='Realtimevalue' styles='captionFont' />\n\
		</application>\n\
	</styles>\n\
</chart>");
   chart1.render("chart1div");
</script>
</s:if>
-->
<!--  <p>&nbsp;</p>
<input type='button' value='Feed Data' onclick="feedData()" id="btnFeed" />
-->
	<input type="button" name="Submit" onclick="javascript:history.back(-1);" value="返回上一页">
</body>
</html>
